package com.cy.controller;

import com.cy.common.pojo.JsonResult;
import com.cy.common.pojo.Node;
import com.cy.pojo.SysMenu;
import com.cy.service.SysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/menu")
public class SysMenuController {
    @Autowired
    private SysMenuService sysMenuService;

    @GetMapping("/selectMenu")
    public JsonResult selectMenu(){
        return new JsonResult(sysMenuService.selectMenu());
    }

    @GetMapping("/selectMenuTreeNodes")
    public JsonResult selectMenuTreeNodes(){
        return new JsonResult(sysMenuService.selectMenuTreeNodes());
    }

    @GetMapping("/selectById/{id}")
    public JsonResult selectById(@PathVariable Integer id){
        return new JsonResult(sysMenuService.selectById(id));
    }

    @PutMapping("/insertMenu")
    public JsonResult insertMenu(@RequestBody SysMenu menu){
        return new JsonResult(sysMenuService.insertMenu(menu));
    }

    @PutMapping("/updateMenu")
    public JsonResult updateMenu(@RequestBody SysMenu menu){
        return new JsonResult(sysMenuService.updateMenu(menu));
    }
}
